var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "../../services/service", "json!websiteConfig"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const service_1 = require("../../services/service");
    const json_websiteConfig_1 = require("json!websiteConfig");
    class LocalService extends service_1.Service {
        url(path) {
            let contexts = requirejs.exec("contexts");
            let context = contexts[json_websiteConfig_1.contextName];
            if (context != null && context.config != null && context.config.baseUrl != null) {
                return `${context.config.baseUrl}${path}`;
            }
            return `${path}`;
        }
        clientFiles() {
            return __awaiter(this, void 0, void 0, function* () {
                let r = yield this.get(this.url(`./clientFiles`));
                return r;
            });
        }
        getPageDataByName(name) {
            return __awaiter(this, void 0, void 0, function* () {
                debugger;
                let record = yield this.get(this.url("./page-data/item"), { name });
                if (record == null)
                    return null;
                return record.pageData;
            });
        }
        getPageDataById(id) {
            return __awaiter(this, void 0, void 0, function* () {
                let record = yield this.get("./page-data/item", { id });
                if (record == null)
                    return null;
                return record.pageData;
            });
        }
        getComponentInfos() {
            return __awaiter(this, void 0, void 0, function* () {
                let r = yield this.get(this.url("user/componentInfos"));
                return r;
            });
        }
    }
    exports.LocalService = LocalService;
});
